// Programming_Scala/src/ch03/match-deep-pair-script.scala

class Role
case object Manager extends Role
case object Developer extends Role

case class Person( name: String, age: Int, role: Role )

val alice = new Person( "Alice", 25, Developer )
val bob = new Person( "Bob", 32, Manager )
val charlie = new Person( "Charlie", 32, Developer )

for( item <- Map( 1 -> alice, 2 -> bob, 3 -> charlie ) ) {
  item match {
    case ( id, p @ Person( _, _, Manager ) ) => println( format( "%s %s is overpaid.", id, p ) )
    case ( id, p @ Person( _, _, _ ) ) => println( format( "%s %s is underpaid.", id, p ) )
  }
}
